<?php
/*
	MoneyTrans Model for Incoming Payment Errors
*/
die();
	// Defaults
	$Sp_Chr = "";
	// File Data
	$f = 1;

	// Orders
	/*###$_sysGetCorrespondentStatusCodeDescription = array(0=>'Na',1=>'Registred',2=>'Incident',3=>'Paid',4=>'Cancelled',5=>'Pre-Cancellation');
	###$_sysGetCorrespondentIncidentCode = array(0=>'Na',1=>'Registred',2=>'In process',3=>'Processed',4=>'Cancelled');
	#$__tftTransactionStatusCode = array('7'=>'1','9'=>'4','11'=>'3');
	###$__tftGetCorrespondentStatusCode = array('3'=>'1','16'=>'2','11'=>'3','9'=>'4');*/

        $_sysGetCorrespondentStatusCodeDescription = array(0=>'Na',1=>'Registred',2=>'Incident',3=>'Paid',4=>'Cancelled',5=>'Pre-Cancellation');
	$_sysGetCorrespondentIncidentCode = array(0=>'Na',1=>'Registred',2=>'In process',3=>'Processed',4=>'Cancelled');
	#$__tftTransactionStatusCode = array('7'=>'1','9'=>'4','11'=>'3');
	$__tftGetCorrespondentStatusCode = array('2'=>'1','3'=>'1','16'=>'1','8'=>'2','11'=>'3','9'=>'4','18'=>'5','19','5');

	$GET = $GLOBALS['MYT']->db_array($QurTrn);

	for($y = 1; $y <= $GET[0]; $y++) {
	$log = '';
	
	echo $TrnID = $GET[$y]['Trs_CorrTrans'];
	
	$TransactionFTName = transaction_filenames($DatadirTransmitionOut,$TrnTime,$TrnID,$CorrCode,$CorrFName,$CorrExt);
	if (!file_exists($DatadirTransmitionOut.$TransactionFTName)) {
	# Single Transaction File
	$handle = fopen($DatadirTransmitionOut.$TransactionFTName, "x");
 
$log .= '<?xml version="1.0" encoding="UTF-8" ?>
<Incident>
<CodeIncident>1315793</CodeIncident>
<CodeTransaction>6950'.str_pad(substr($GET[$y]['FraIncReferenciaCo'],0,10), 10, "0", STR_PAD_LEFT).'</CodeTransaction>
<TransactionVersion>'.$GET[$y]['FraIncVersion'].'</TransactionVersion>
<CodeIncidentStatus>'.$__tftGetCorrespondentStatusCode[$GET[$y]['FraStatus']].'</CodeIncidentStatus>
<IncidentStatusDescription>'.$_sysGetCorrespondentStatusCodeDescription[$__tftGetCorrespondentStatusCode[$GET[$y]['FraStatus']]].'</IncidentStatusDescription>
<IncidentDescription>'.$_sysGetCorrespondentStatusCodeDescription[$__tftGetCorrespondentStatusCode[$GET[$y]['FraNotas']]].'</IncidentDescription>
<DateIncident>
<Year>2010</Year>
<Month>10</Month>
<Day>20</Day>
<Hour>16</Hour>
<Min>28</Min>
<Sec>51</Sec>
</DateIncident>
<FieldToModify>
<FieldName>CodeTransactionStatus</FieldName>
<FieldOldValue>REG</FieldOldValue>
<FieldNewValue>CCL</FieldNewValue>
</FieldToModify>
</Incident>';

	fwrite($handle,$log);
	fclose($handle);

	## copia ficheiro para pasta ftp
		if (!copy($DatadirTransmitionOut.$TransactionFTName, $GetSettings[1]['set_Valor'].'//'.$GETCOMMETH[1]['CorrAgente'].'//OUT//'.$TransactionFTName)) {
				  $Exception_error = 'Error copying file.';
		} else {
			$Msg_OPCONFIRM = 'J� Existe';
		}
	}
	}

?>